package com.proj.hot.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.util.AttributeSet;
import android.widget.ImageView;

import com.proj.hot.utils.DebugUtil;

/**
 * Created by zangchenggang on 17/10/22.
 */
public class CustomImageView extends ImageView {


    private PaintFlagsDrawFilter pfd;
    private Paint mPaint = new Paint();

    public CustomImageView(Context context) {
        super(context);
        pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
        mPaint.setAntiAlias(true);
    }

    public CustomImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
        pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
        mPaint.setAntiAlias(true);
    }

    public CustomImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
        mPaint.setAntiAlias(true);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        DebugUtil.i("gggggl","执行drawChild（）CustomImageview onDraw");
        canvas.setDrawFilter(pfd);
    }

    @Override
    protected void dispatchDraw(Canvas canvas) {
        DebugUtil.i("gggggl","dispatchDraw（）CustomImageview dispatchDraw");
        super.dispatchDraw(canvas);
        canvas.setDrawFilter(pfd);
    }
}
